{extend  name="manage@public/layout" /}
{block name="style"}
<style type="text/css">
    table thead, table tr {border-top-width: 1px;border-top-style: solid;border-top-color: rgb(230, 189, 189);}
    table {border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: rgb(230, 189, 189);}
    table td, table th {font-size: 12px;font-family: Verdana;color: rgb(177, 106, 104);}
    table tr:nth-child(even) {background: rgb(238, 211, 210)}
    table tr:nth-child(odd) {background: #FFF}
</style>
{/block}
{block name="content"}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
    
        <div class="row">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a data-toggle="tab" href="#tab-1" aria-expanded="true"> 支付下单</a>
                        </li>
                        <li class="">
                            <a data-toggle="tab" href="#tab-2" aria-expanded="false">订单查询</a>
                        </li>
                        <li class="">
                            <a data-toggle="tab" href="#tab-3" aria-expanded="false">余额查询</a>
                        </li>
                        <li class="">
                            <a data-toggle="tab" href="#tab-4" aria-expanded="false">签名规则</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body">
                                <div class="col-sm-12">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-content">
                                            <div class="ibox float-e-margins">
                                                <h4><a id="user-content-调用-pay接口须遵守以下规则" class="anchor" aria-hidden="true" href="#调用pay接口须遵守以下规则"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" ></path></svg></a>调用Pay接口须遵守以下规则：</h4>
                                                <ol>
                                                    <li><p>统一以对象行式 POST提交</p></li>
                                                    <li><p>字符串编码请统一使用UTF-8</p></li>
                                                </ol>
                                                <h3><a id="user-content-13-请求头" class="anchor" aria-hidden="true" href="#13-请求头"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" ></path></svg></a>1.3 请求头</h3>
                                                <pre>
                                                    <code >Content-Type: application/json; charset=utf-8</code>
                                                </pre>
                                                <h2> 下单接口地址</h2>
                                                <pre>
                                                    <code><?php echo 'http://'.$_SERVER['SERVER_NAME'];?>/pay/gateway</code>
                                                </pre>
                                                <h3><a class="anchor" aria-hidden="true" ><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd"></path></svg></a> 请求参数</h3>
                                                <table>
                                                    <thead>
                                                        <tr>
                                                            <th style="width:100px;">字段</th>
                                                            <th style="width:100px;">变量名</th>
                                                            <th style="width:100px;">必填</th>
                                                            <th style="width:100px;">是否签名</th>
                                                            <th style="width:100px;">类型</th>
                                                            <th>描述</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <tr>
                                                            <td>商户号</td>
                                                            <td>mch_id</td>
                                                            <td>是</td>
                                                            <td>是</td>
                                                            <td>String</td>
                                                            <td>mch_id,开户时由平台下发</td>
                                                        </tr>
                                                        <tr>
                                                            <td>订单号</td>
                                                            <td>out_trade_no</td>
                                                            <td>是</td>
                                                            <td>是</td>
                                                            <td>String</td>
                                                            <td>纯数字或者英文和数字的组合，32位以下</td>
                                                        </tr>
                                                        <tr>
                                                            <td>金额</td>
                                                            <td>amount</td>
                                                            <td>是</td>
                                                            <td>是</td>
                                                            <td>String</td>
                                                            <td>以分为单位</td>
                                                        </tr>
                                                        <tr>
                                                            <td>异步回调</td>
                                                            <td>callback_url</td>
                                                            <td>是</td>
                                                            <td>是</td>
                                                            <td>String</td>
                                                            <td>支付成功后异步通知的地址，不能带参数</td>
                                                        </tr>
                                                        <tr>
                                                            <td>同步跳转</td>
                                                            <td>return_url</td>
                                                            <td>是</td>
                                                            <td>否</td>
                                                            <td>String</td>
                                                            <td>支付成功后跳转地址，不能带参数</td>
                                                        </tr>
                                                        <tr>
                                                            <td>支付类型编码</td>
                                                            <td>service_type</td>
                                                            <td>是</td>
                                                            <td>是</td>
                                                            <td>String</td>
                                                            <td>wxqr(微信扫码) wxwap(微信wap) aliqr(支付宝扫码) aliwap(支付宝wap) quick(快捷) unionpay(银联扫码)</td>
                                                        </tr>
                                                        <tr>
                                                            <td>商品描述</td>
                                                            <td>goods</td>
                                                            <td>是</td>
                                                            <td>否</td>
                                                            <td>String</td>
                                                            <td>商品描述，可填中文16个字符以下</td>
                                                        </tr>
                                                        <tr>
                                                            <td>签名</td>
                                                            <td>sign</td>
                                                            <td>是</td>
                                                            <td>是</td>
                                                            <td>String</td>
                                                            <td>参照签名规则</td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                
                                                <h3><svg class="octicon octicon-link" width="16" height="16"><path fill-rule="evenodd"></path></svg>请求示例</h3>
                                                <pre><code style="white-space: pre-line !important;">
                                                    {
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"mch_id": "8197581366",  商户号
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"out_trade_no": "1801908270928163420359", 商户订单号
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"amount": "30000", 金额 单位：分
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"service_type": "aliwap", 支付类型
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"goods": "测试",  商品描述
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"callback_url": "http://www.baidu.cn",  异步通知
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"return_url": "http://www.baidu.cn",  同步跳转
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"sign": "769ABB87CDF4564C05FBC56C1CC9EDCB",  签名
                                                    }
                                                </code></pre>
                                                <p>正确响应结果</p>
                                                <pre><code style="white-space: pre-line !important;">
                                                        {
                                                            &nbsp;&nbsp;&nbsp;&nbsp;"code": "1",
                                                            &nbsp;&nbsp;&nbsp;&nbsp;"data": {
                                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"out_trade_no": "1801908270928163420359", 商户订单号
                                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"system_sn": "KF829567047109687538098", 平台订单号
                                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"link_url": "http://www.ruan.cn/gateway?parameter=KF829567047109687538098" 支付url
                                                                &nbsp;&nbsp;&nbsp;&nbsp;}
                                                        }
                                                </code></pre>
                                                <p>错误响应结果</p>
                                                <pre><code style="white-space: pre-line !important;">
                                                        {
                                                            &nbsp;&nbsp;&nbsp;&nbsp;"code": "0",
                                                            &nbsp;&nbsp;&nbsp;&nbsp;"msg": "订单已存在" 错误提示
                                                        }
                                                </code></pre>
                                                <h3><a id="" class="anchor" aria-hidden="true" ><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>POST异步通知示例：</h3>
                                                <h4 style="color:rgb(252, 5, 5);">响应 success;</h4>
                                                <pre><code style="white-space: pre-line !important;">
                                                    {
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"mch_id":"8197581366", 商户号
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"out_trade_no":"3661908251103227396650", 商户订单号
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"systen_no":"KF825566745403016737634", 平台订单号
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"amount":"500.000", 提交金额 单位：元
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"actual_amount":"500.000", 实际支付金额 单位：元
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"pay_time":"1575008482", 支付时间
                                                        &nbsp;&nbsp;&nbsp;&nbsp;"sign":"BEBF5C7FDA3736D260FACA9F4CD6F4D9" 签名
                                                    }
                                                </code></pre>
                                                </article>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                订单查询
                            </div>
                        </div>
                        <div id="tab-3" class="tab-pane">
                            <div class="panel-body">
                                余额查询
                            </div>
                        </div>
                        <div id="tab-4" class="tab-pane">
                            <div class="panel-body">
                                <div style="padding:20px;border-color:rgb(204,204,204);height: 230px;background-color:rgb(245,245,245);">
                                    <p>1、所有不为空的字段按照参数名ASCII码从小到大排序（字典序）</p>
                                    <p>2、使用URL键值对的格式,即key=value&key2=value2 拼接成字符串</p>
                                    <p>3、在字符串末尾拼接上&KEY=商户秘钥</p>
                                    <p>4、得到最终签名串进行MD5加密后转大写</p>
                                    最终签名串示例：
                                    <pre><code>amount=10000&mch_id=1000108000&out_trade_no=1577528801&callback_url=http://www.pay.cn/pay/test/callback&service_type=aliqr&KEY=be58a54320e04be7ba026719ec2517b9</code></pre>
                                </div>
                                <h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"></svg> PHP签名示例代码：</h3>
                                <pre><code>&lt;?php
                                /*
                                * 参数数组数据签名
                                * @param array $obj 数组
                                * @param string $KEY 密钥
                                * @return string 签名
                                */
                                function get_sign($obj,$KEY){
                                    $signPars = "";
                                    ksort($obj);//排序
                                    foreach($obj as $k => $v){
                                        if("" != $v && "sign" != $k && 'goods' != $k && 'return_url' != $k){
                                            $signPars .= $k . "=" .$v . "&";
                                        }
                                    }
                                    $signPars .= "KEY=" . $KEY;
                                    $my_sign = strtoupper(md5($signPars));
                                    return $my_sign;
                                }
                                </code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>   
    {/block}
